package com.runfingers.bench;

import java.util.Calendar;
import java.util.Date;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;

public class UserFindEventActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_user_find_event);
		
		//get current time 
		Calendar currDate = Calendar.getInstance();
		currDate.setTime(new Date());
		//spinner will display today and following 6 days
		int today = currDate.get(Calendar.DAY_OF_WEEK);
		//Log.e("bench","today is SAT: " + today);
		String[] days = new String[7];
		String[] alldays = getResources().getStringArray(R.array.when_array);
		days[0] = alldays[0]; //today
		//all following are the day of the week + 1..6 matching to appropriate day of the week
		// so if today is TUE, today=3, which means that days[1]="wednesday"(3), days[2]="thursday"(4), etc
		// alldays contains TODAY, MON, TUE, WED,... (so string values for days)
		for (int i=1; i<7; i++){
			days[i] = alldays[(today+i)%7];
		}
		//put second one as "Tomorrow"
		days[1] = "Tomorrow";
		
		//When Drop Down Object
		Spinner whereSpinner = (Spinner) findViewById(R.id.whereSpinner);
		ArrayAdapter<String> adapterDays = new ArrayAdapter<String>(this,   android.R.layout.simple_spinner_dropdown_item, days);
		adapterDays.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		whereSpinner.setAdapter(adapterDays);
		
		Spinner whatSpinner = (Spinner)findViewById(R.id.whatSpinner);
		ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.what_array, android.R.layout.simple_spinner_item);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		whatSpinner.setAdapter(adapter);
		
		Spinner whereDistanceSpinner = (Spinner)findViewById(R.id.whereDistanceSpinner);
		adapter = ArrayAdapter.createFromResource(this, R.array.radius_array, android.R.layout.simple_spinner_item);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		whereDistanceSpinner.setAdapter(adapter);
		
		Button userPerspectiveBtn = (Button) findViewById(R.id.findActivityBtn);
		userPerspectiveBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View view) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(view.getContext(), ResultActivity.class);
				startActivityForResult(intent, 0); 
				
			}
		});
		
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.user_find_event, menu);
		return true;
	}

}
